import { observable, action } from 'mobx';
import { WeaForm } from 'comsMobx';import * as mobx from 'mobx'

/**
 * 报表列表通用store模板，适应于列表+高级查询模式
 */
export class ListStoreCharts{
    /** 列表store */
    @observable loading = false;
    @observable title = "";
    
    /** 高级查询store */
    @observable form = new WeaForm();
    @observable showSearchAd = false;
    @observable condition = [];

    /** 路由 **/
    router = {};

    //标识哪个页面
    pageType = '';

    //权限
    permisflag = "success";// ""有权限 ,failed无权限
    havePermis = "0";//0有权限且不存在不能查的,1有权限且存在不能查的

    constructor() {
    }

    @action
    setLoading = (bool = false) => {
        this.loading = bool;
    }
    
    //标题
    setTitle = (title) => {
        this.title = title;
    }

    //高级搜索显隐
    setShowSearchAd = (bool) => {
        this.showSearchAd = bool;
        this.permisflag = "success";
        this.havePermis = "0";
    }

    //true代表完全覆盖方式更新条件值
    setFormFields = (value) => {
        this.form.updateFields(value, true);    
    }

    appendFormFields = (value) => {
        this.form.updateFields(value, false);
    }

    //重置
    clearFormFields = (key) =>{
        this.form.resetConditionValue();//清除查询条件值  
    }
    
    //设置路由
    setRouter = (value) => {
        this.router = value;
    }

    @action
    //设置权限
    setPermisflag = (value) => {
        this.permisflag = value;
    }

    @action
    //设置权限
    setHavePermis = (value) => {
        this.setHavePermis = value;
    }
}